#!/usr/bin/env python
#-*- coding:utf-8 -*-
# 

#Copyright (c) 2009 

#file: makeversion.py
#date: 2015-10-12 09:26:01
#author: chuanjiang.zh@qq.com
#desc: 
#

import sys
import ctypes as C


def getMediaInfo(filepath):
    print(filepath)
    infoDll = C.cdll.LoadLibrary('D:\\Haitu\HiRec\\FfMediaInfo\\bin\\FfMediaInfo.dll')
    # result1 = infoDll.add1(2,3)
    # print("传入实数调用demo:")
    # print(result1)

    # result2 = C.c_int(0)#定义int类型变量，初始值为0
    # infoDll.add2(4, 5, C.byref(result2))#byref指明参数传递时为引用传递，对应C中的指针传递
    # print("传入指针调用demo1:")
    # print(result2.value)#.value可以查看变量的值

    framerate = C.c_double(0)
    filepath = C.c_char_p(b'g:\\haitu\\1920-1080.ts')
    infoDll.ff_getFrameRate(filepath, C.byref(framerate))
    print(framerate.value)

    duration = C.c_int(0)
    frameCount = C.c_int(0)
    infoDll.ff_getVideoFrameInfo(filepath, C.byref(framerate), C.byref(duration), C.byref(frameCount))
    print(framerate.value)
    print(duration.value)
    print(frameCount.value)

if __name__ == "__main__":
    if len(sys.argv) > 1:
        getMediaInfo(sys.argv[1])
    else:
        print('''FfMediaInfo.py filename''')
    
